﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Xunit;

namespace MyDemo.Linq
{
    public class LinqDemo
    {
        private List<string> _list = null;

        public LinqDemo()
        {
            _list = new List<string>() { "张三", "张三", "王五", "李四", "张三", "李四", "张三", "李四" };

        }

        [Fact]
        public void WhereTest()
        {

            var people = _list
                .Where((item, index) => item == "王五" && index == 2)
                .Select((item, index) => new { item, index });

            foreach (var item in people)
            {
                Debug.WriteLine(item.ToString());
            }
        }


        [Fact]
        public void ReverseTest()
        {
            _list.Reverse();

            foreach (var item in _list)
            {
                Debug.Write(item.ToString() + " ");
            }
        }
    }
}